/*  This file is part of the comicconquer project
    Copyright (C) 2010 Reach <reach334@gmail.com>

    ComicConquer is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This software is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public 
    License along with this software.  If not, see <http://www.gnu.org/licenses/>.

*/

#ifndef SETTINGDLG_H
#define SETTINGDLG_H

#include "mist.h"
#include "onyx/ui/tab_bar.h"
#include "onyx/ui/buttons.h"
#include "onyx/ui/onyx_dialog.h"
#include "Configuration.h"
#include "KeyPage.h"
#include "GesturePage.h"
#include "CoTabPage.h"

class SettingDlg : public ui::OnyxDialog
{
    Q_OBJECT
    CO_MOUSECONTROL
public slots:
    void mouseCtlEvent(GestureEvent* event);

    //-- constructor
public:
    SettingDlg(CoconProfile* profile, QWidget* parent = 0);

    //-- public methods
public:
    bool popup();

    //-- public slots
public slots:
    void keyPressEvent(QKeyEvent* event);

    //-- private methods
private:
    void refreshScreen(ScreenProxy::Waveform w = ScreenProxy::GU, bool whole = false);
    void addPage(CoTabPage* tabPage, const QString& title, int id);
    void buildModePage();
    void initModePage();
    void saveModePage();
    void buildViewPage();
    void initViewPage();
    void saveViewPage();

    //-- private slots
private slots:
    bool event(QEvent* e);
    void tabbarClicked(const int id);
    void clickedOK();

    //-- private members
private:
    /// ui
    // window 
    QVBoxLayout m_vlayout;
    QHBoxLayout m_hlayoutDown;
    ui::TabBar m_tabbar;
    ui::OnyxPushButton m_bOK;
    ui::OnyxPushButton m_bCancel;

    // tab pages
    QVector<QScrollArea*> m_vcScrArea;
    QVector<CoTabPage*> m_vcPage;
    QVBoxLayout m_layoutTab;
    CoTabPage* m_modePage; 
    CoTabPage* m_viewPage;
    KeyPage* m_keyPage;
    GesturePage* m_gesturePage;
    CoTabPage* m_aboutPage;

    /// profile
    CoconProfile* m_profile;

    /// control arguments
    bool m_isKeyPageInited; // whether the keyPage is initialized this time popup
    bool m_isGesturePageInited; // ditto
};

#endif // SETTINGDLG_H
